Skip to content

Conversation

@MoMannn
Copy link
Contributor

@MoMannn MoMannn commented Oct 2, 2025

Description

If permission is being done by an account that has not been transformed to Smart account then we trigger an account upgrade.

Related issues

Depends on: MetaMask/metamask-extension#36452

Manual testing steps

  1. Go localhost:8000
  2. Make sure your account is not a smart account
  3. Grant a new permission
  4. Permission page should show a warning that your account will be upgraded
  5. After clicking grant first a transaction for upgrading the account should show

Screenshots/Recordings

After

Screen.Recording.2025-10-02.at.14.33.28.mov

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Adds smart account upgrade check/trigger to the permission flow with UI warning and supporting chain metadata; includes tests.

  • Core:
    • AccountController: Add getAccountUpgradeStatus(params) and upgradeAccount(params) using wallet_getAccountUpgradeStatus and wallet_upgradeAccount; wrap failures with InternalError.
    • Permission Orchestrator: After user approval, verify upgrade status and trigger upgradeAccount if needed before resolving permission.
    • Permission Handler: Parallelize confirmation content creation with upgrade status fetch; pass isAccountUpgraded to UI.
    • UI (PermissionHandlerContent): Show warning text when isAccountUpgraded is false; minor TokenBalanceField prop tweak.
    • Chain Metadata: Add contracts.eip7702StatelessDeleGatorImpl address.
  • Tests: Add/adjust tests for upgrade status, upgrade execution, UI warning, and chain metadata contract.

Written by Cursor Bugbot for commit 49df0d1. This will update automatically on new commits. Configure here.

@mj-kiwi
Copy link
Contributor

mj-kiwi commented Oct 6, 2025

Looks good! I think it’d be better to update the docs to include this new feature.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@MoMannn MoMannn requested a review from mj-kiwi October 7, 2025 14:20
cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! A couple minor comments.

Comment on lines +211 to +212
result.upgradedAddress?.toLowerCase() ===
eip7702StatelessDeleGatorImpl.toLowerCase(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that the wallet is making this check. If that is the case should we be duplicating the check here?

On the one hand, the result should always be the eip7702StatelessDeleGatorImpl address, so this probably isn't harmful.

On the other hand, the wallet is the arbiter of which account should be upgraded to, so if for some reason the wallet is upgrading to a different account (maybe we deploy an updated version of the Eip7702Stateless contract that is otherwise backwards compatible), the snap will need to be updated also. Presently the wallet receives the contract address to delegate to via over-the-air configuration, so this delegation address could be changed without a software update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wallet is not checking the address to which is upgraded. Also I'm thinking there can be multiple versions of the stateless contract and we would need to know to which contracts its upgraded and suggest and upgrade if its not to the one we need?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a complex problem, because we can't request a specific account, just that the account is upgraded, so it seems counterintuitive that the caller cannot specify the target when upgrading, but must know about the desired address when checking if it's upgraded.

I would expect more like a get_capabilities call, where the caller asks whether the EOA is a MetaMask Smart Account.

@MoMannn MoMannn requested a review from jeffsmale90 October 24, 2025 08:47
Copy link
Contributor

@jeffsmale90 jeffsmale90 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good.

I still have a concern about how we manage the delegated contract address - but that's a bigger question, which we should probably discuss outside of the context of this PR.

We can either hold off on merging this until that question is resolved, or merge this and revisit once we have a decision (I prefer the former, in the interests of expediency).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants